package com.nforce.linremote.model;

import android.os.Bundle;

public class Program {

    private final String interfeiz;
    private String name;
    private String scriptName;
    private Script script;

    public Program(String interfeiz) {
	this.interfeiz = interfeiz;
    }

    public Program(String interfeiz, String scriptName, boolean loadFull) {
	this.interfeiz = interfeiz;
	this.scriptName = scriptName;
	this.script = loadScript(loadFull);
    }

    public Program(Bundle bundle, boolean loadFull) {
	this.interfeiz = bundle.getString("interfeiz");
	this.scriptName = bundle.getString("scriptName");
	this.script = loadScript(loadFull);
    }

    public String getInterfeiz() {
	return interfeiz;
    }

    public String getName() {
	return name;
    }

    public Script getScript() {
	return script;
    }

    public String getScriptName() {
	return scriptName;
    }

    private Script loadScript(boolean loadFull) {
	if (scriptName == null) {
	    return null;
	}
	Script result = new Script(scriptName, interfeiz, loadFull);
	this.name = result.getProgramName();
	return result;
    }

    public Bundle toBundle() {
	Bundle bundle = new Bundle();
	bundle.putString("interfeiz", interfeiz);
	bundle.putString("scriptName", scriptName);
	return bundle;
    }
}
